package top.ninwoo.utils.entity;

public class BridgePort {
    private String portId;
    private String interfaceId;
    private String error;

    public BridgePort() {
        this.error = "";
    }

    public BridgePort(String portId, String interfaceId, String error) {
        this.portId = portId;
        this.interfaceId = interfaceId;
        this.error = error;
    }

    public static class Builder {
        private String portId;
        private String interfaceId;
        private String error;

        public Builder() {
            this.error = "";
        }

        public String portId() {
            return this.portId;
        }

        public BridgePort.Builder portId(String portId) {
            this.portId = portId;
            return this;
        }

        public String interfaceId() {
            return this.interfaceId;
        }

        public BridgePort.Builder interfaceId(String interfaceId) {
            this.interfaceId = interfaceId;
            return this;
        }

        public String error() {
            return this.error;
        }

        public BridgePort.Builder error(String error) {
            this.error = error;
            return this;
        }

        public BridgePort build() {
            return new BridgePort(this);
        }
    }

    public BridgePort(BridgePort.Builder builder) {
        if(builder.portId == null || builder.portId().equals("")) {
            throw new RuntimeException("portId cannot be null or empty");
        }
        this.portId = builder.portId;
        this.error = builder.error;
        this.interfaceId = builder.interfaceId;
    }

    public static BridgePort.Builder builder() {
        return new BridgePort.Builder();
    }

    public String getPortId() {
        return portId;
    }

    public void setPortId(String portId) {
        this.portId = portId;
    }

    public String getInterfaceId() {
        return interfaceId;
    }

    public void setInterfaceId(String interfaceId) {
        this.interfaceId = interfaceId;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof BridgePort) {
            return this.error.equals(((BridgePort) obj).getError())
                    && this.interfaceId.equals(((BridgePort) obj).getInterfaceId())
                    && this.portId.equals(((BridgePort) obj).getPortId());
        }
        return false;
    }
}
